package com.deercrowing.takeaway.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.deercrowing.takeaway.vo.SetmealDishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import com.deercrowing.takeaway.entity.SetmealDishEntity;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * 套餐菜品映射表(SetmealDish)表数据库访问层
 *
 * @author guoyongxiang
 * @since 2024-08-22 15:09:40
 */
@Mapper
public interface SetmealDishMapper extends BaseMapper<SetmealDishEntity> {

    /**
     * 根据套餐ID，搜索套餐菜品信息
     *
     * @param id
     * @return
     */
    @Select("select d.name,d.price,sd.copies,sd.setmeal_id,sd.dish_id from tb_setmeal_dish sd,tb_dishes d where sd.dish_id = d.id and sd.setmeal_id = #{id}")
    List<SetmealDishVO> seletctListBySetmealId(Long id);

    /**
     * 批量插入数据
     *
     * @param setmealDishVOList
     */
    void insertBatch(List<SetmealDishVO> setmealDishVOList);

    /**
     * 根据套餐ID删除数据
     *
     * @param setmealId
     */
    @Delete("delete from tb_setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Integer setmealId);

    /**
     * 根据套餐ID批量搜索数据
     *
     * @param idList
     * @return
     */
    List<Integer> selectBySetmealId(List<Integer> idList);
}

